import drawQrcode from '../../utils/weapp.qrcode.esm.js'
const app = getApp()

Page({
  data: {
    // message: "干净又卫生"
    message: "https://www.baidu.com/"
  },
  handleScan() {
    wx.scanCode({
      onlyFromCamera: true,
      success (res) {
        app.globalData.scanCodeResult = res.result
        console.log(res.result)
        // ^https://
        // ^http://
        // <web-view src="https://www.baidu.com/"></web-view>
        wx.navigateTo({
          url: "../logs/logs"
        })
      }
    })
  },
  handleChange(event) {
    this.setData({
      message: event.detail
    })
  },
  handleSubmit() {
    drawQrcode({
      width: 200,
      height: 200,
      canvasId: 'myQrcode',
      text: this.data.message,
      background: "#00fff0",
      foreground: "#ff0f00",
      // x: 100,
      // y: 50,
      image: {
        imageResource: '../../images/banner/wbb.jpeg',
        dx: 80,
        dy: 80,
        dWidth: 40,
        dHeight: 40
      },
      callback(res) {
        wx.vibrateLong()
      }
    })
  },
  onLoad: function (options) {
    this.handleSubmit()
    /*drawQrcode({
      width: 200,
      height: 200,
      canvasId: 'myQrcode',
      text: this.data.message,
      background: "#00fff0",
      foreground: "#ff0f00",
      // x: 100,
      // y: 50,
      image: {
        imageResource: '../../images/banner/wbb.jpeg',
        dx: 80,
        dy: 80,
        dWidth: 40,
        dHeight: 40
      },
      callback(res) {
        console.log(res)
      }
    })*/
  },
})
